package com.myprojects.authenticationservice.service;

import com.myprojects.common.dto.Msg;
import com.myprojects.common.pojo.UserWithRole;
import com.myprojects.common.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

@Service
@FeignClient(name = "permission-service",
        contextId = "permission-service-api1"
//        ,
//        fallback = FeignPermissionServiceFallback.class
)
public interface FeignAuthenticationService {

    /**
     * 该方法用于使用用户信息来登录
     */
    @RequestMapping(value = "/login-by-info",method = RequestMethod.POST)
    public Msg loginByUser(UserWithRole user);

    /**
     * 该方法用于使用用户信息来注册
     */
    @RequestMapping(value = "/register",method = RequestMethod.POST)
    public Msg register( UserWithRole user);

    /**
     * 该方法用于检查用户注册的信息
     */
    @RequestMapping(value = "/register",method = RequestMethod.PUT)
    public Msg checkRegister(UserWithRole user);

    /**
     * 该方法用于修改密码
     */
    @RequestMapping(value = "/password",method = RequestMethod.POST)
    public Msg updatePassword(@RequestHeader("accessToken") String accessToken, @RequestBody UserWithRole user);

    /**
     * 该方法用于检查修改密码
     */
    @RequestMapping(value = "/password",method = RequestMethod.PUT)
    public Msg checkUpdatePassword(UserWithRole user);

    /**
     * 该方法用于使用用户token来注销登录
     */
    @RequestMapping(value = "/logout-by-token",method = RequestMethod.POST)
    @ResponseBody
    public Msg logoutByToken(@RequestHeader("accessToken") String accessToken);
}
